package com.geqian.web.controller;
import com.geqian.common.common.PageRequest;
import com.geqian.common.common.PageResult;
import com.geqian.common.common.ResponseResult;
import com.geqian.web.entity.${className};
import com.geqian.web.service.${className}Service;
import com.geqian.web.common.dto.${className}Dto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import org.springframework.validation.annotation.Validated;


/**
* ${description}控制器
* @author ${author}
* @date ${date}
*/
@RestController
@RequestMapping("/${className?uncap_first}")
@Api(tags = "${description}")
public class ${className}Controller {

    @Resource
    private ${className}Service ${className?uncap_first}Service;

    @ApiOperation("获取${description}列表")
    @GetMapping("/get${className}List")
    public ResponseResult<PageResult<${className}>> get${className}List(PageRequest pageRequest){
        return ${className?uncap_first}Service.get${className}List(pageRequest);
    }


    @ApiOperation("更新${description}")
    @PostMapping("/update${className}")
    public ResponseResult<String> update${className}(@Validated @RequestBody ${className}Dto ${className?uncap_first}Dto, @RequestHeader("token") String token) {
        return ${className?uncap_first}Service.update${className}(${className?uncap_first}Dto, token);
    }


    @ApiOperation("新增${description}")
    @PostMapping("/add${className}")
    public ResponseResult<String> add${className}(@Validated @RequestBody ${className}Dto ${className?uncap_first}Dto, @RequestHeader("token") String token) {
        return ${className?uncap_first}Service.add${className}(${className?uncap_first}Dto, token);
    }

    @ApiOperation("删除${description}")
    @PostMapping("/delete${className}")
    public ResponseResult<String> delete${className}(@RequestBody List<${className}> ${className?uncap_first}List) {
        return ${className?uncap_first}Service.delete${className}(${className?uncap_first}List);
    }

}